<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('users', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('username')->unique()->comment('用户名');
            $table->string('password')->comment('密码');
            $table->string('avatar',150)->nullable()->comment('头像');
            $table->string('email')->nullable()->index()->comment('电子邮箱');
            $table->string('mobile')->nullable()->index()->comment('手机号');
            $table->unsignedSmallInteger('status',false)->default(0)->comment('状态');
            $table->dateTime('reg_time')->comment('注册时间');
            $table->ipAddress('reg_ip')->nullable()->comment('注册ip');
            $table->dateTime('current_login_time')->nullable()->comment('当前登录时间');
            $table->ipAddress('current_login_ip')->nullable()->comment('当前登录ip');
            $table->dateTime('last_login_time')->nullable()->comment('上次登录时间');
            $table->ipAddress('last_login_ip')->nullable()->comment('上次登录ip');
            $table->timestamps();
            $table->softDeletes();
            $table->engine="InnoDb";
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('users');
    }
}
